import random

# 初始化信息
countries = ["美国", "中国", "俄罗斯", "英国", "法国"]
issues = ["气候变化", "地区冲突", "贸易争端", "难民问题"]
veto_countries = ["美国", "中国", "俄罗斯", "英国", "法国"]

# 国家对议题的态度（随机初始化）
country_attitudes = {
    country: {issue: random.randint(-10, 10) for issue in issues}
    for country in countries
}

# 联合国主席信息
chairman = {
    "威望": 50,
    "外交能力": 50
}


# 显示当前情况
def show_status():
    print("当前议题及各国态度：")
    for issue in issues:
        print(f"{issue}:")
        for country, attitude in country_attitudes.items():
            print(f"  {country}: {'支持' if attitude[issue] > 0 else '反对' if attitude[issue] < 0 else '中立'}")
    print(f"主席威望: {chairman['威望']}")
    print(f"主席外交能力: {chairman['外交能力']}")


# 提出新议题
def propose_issue():
    new_issue = input("请提出一个新的议题: ")
    issues.append(new_issue)
    for country in countries:
        country_attitudes[country][new_issue] = random.randint(-10, 10)
    print(f"成功提出新议题: {new_issue}")


# 协调各国关系
def coordinate_relations():
    issue = input("请选择要协调的议题: ")
    if issue not in issues:
        print("该议题不存在。")
        return
    # 主席外交能力影响协调结果
    success_chance = (chairman['外交能力'] + 50) / 100
    if random.random() < success_chance:
        for country in countries:
            if country_attitudes[country][issue] < 0:
                country_attitudes[country][issue] += 5
            elif country_attitudes[country][issue] > 0:
                country_attitudes[country][issue] += 3
        chairman['威望'] += 5
        print("协调成功，各国态度有所改善，主席威望提升 5 点。")
    else:
        chairman['威望'] -= 3
        print("协调失败，主席威望下降 3 点。")


# 推动决议通过
def push_resolution():
    issue = input("请选择要推动通过的议题: ")
    if issue not in issues:
        print("该议题不存在。")
        return
    support_count = 0
    veto = False
    for country, attitude in country_attitudes.items():
        if attitude[issue] > 0:
            support_count += 1
        if attitude[issue] < 0 and country in veto_countries:
            veto = True
    if veto:
        print("有常任理事国行使否决权，决议未能通过。")
        chairman['威望'] -= 5
    elif support_count >= len(countries) // 2 + 1:
        print("决议通过！")
        chairman['威望'] += 10
    else:
        print("支持的国家数量不足，决议未能通过。")
        chairman['威望'] -= 3


# 主游戏循环
while True:
    show_status()
    print("\n请选择操作：")
    print("1. 提出新议题")
    print("2. 协调各国关系")
    print("3. 推动决议通过")
    print("4. 结束游戏")
    choice = input("请输入选项编号: ")
    if choice == "1":
        propose_issue()
    elif choice == "2":
        coordinate_relations()
    elif choice == "3":
        push_resolution()
    elif choice == "4":
        print("游戏结束，感谢你的参与！")
        break
    else:
        print("无效的选项，请重新输入。")